package com.rscache.exception;

/**
 * 异常基类
 * @ClassName: RscacheException  
 * @Description: TODO(这里用一句话描述这个类的作用)  
 * @author "Linfeng Han"  
 * @date 2017年1月4日 下午3:40:59
 *
 */
public class RscacheException extends RuntimeException {

	private static final long serialVersionUID = 6040721435393010636L;

	protected String errorCode;

	protected String errorMsg;

	protected Exception exception;

	public Exception getException() {
		return exception;
	}

	public void setException(Exception exception) {
		this.exception = exception;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public RscacheException() {
	}

	public RscacheException(String errorCode, String errorMsg) {
		this.exception = new RuntimeException();
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	public RscacheException(RscacheErrorCode rscacheErrorCode) {
		this.exception = new RuntimeException();
		this.errorCode = rscacheErrorCode.getCode();
		this.errorMsg = rscacheErrorCode.getMsg();
	}

	@Override
	public String getMessage() {
		return errorMsg + "(" + errorCode + ")";
	}
}